/**
 * 桥梁模式、桥接模式
 */

abstract class Product {
  abstract beProduced(): void
  abstract beSell(): void
}

abstract class Corp {
  product: Product = null;
  constructor(_product: Product) {
    this.product = _product;
  }
  makeMoney() {
    this.product.beProduced()
    this.product.beSell()
  }
}

class ShanZhaiCorp extends Corp {
  constructor(_product: Product) {
    super(_product)
  }
  makeMoney(): void {
    super.makeMoney()
    console.log('山寨公司赚翻了');
  }
}

class IPod extends Product {
  beProduced(): void {
    console.log('IPod被生产了');
  }
  beSell(): void {
    console.log('IPod被卖掉了');
  }
}
class IPad extends Product {
  beProduced(): void {
    console.log('IPad被生产了');
  }
  beSell(): void {
    console.log('IPad被卖掉了');
  }
}

function main() {
  const iPod = new IPod()
  const shanZhaiCorp1 = new ShanZhaiCorp(iPod)
  shanZhaiCorp1.makeMoney()

  console.log('-------');
  const iPad = new IPad()
  const shanZhaiCorp2 = new ShanZhaiCorp(iPad)
  shanZhaiCorp2.makeMoney()
}

main()